from django.shortcuts import render
from django.shortcuts import redirect
from django.http import HttpResponse
# Create your views here.
import json


def login(request):
	method = request.method
	if method == 'POST':
		print('POST')
		img = request.FILES.get('fi')
		if img:
			print('IMG')
			f = open(img.name,'wb')
			for x in img.chunks():
				f.write(x)
			f.close()

		user = request.POST.get('username')	
		pwd = request.POST.get('pwd')
		if user == 'root' and pwd == '111':
			return redirect('/home')
	return render(request, 'app1/login.html')


def home(request):
	return HttpResponse("登录成功")
